﻿<Window x:Class="FSquirrel.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:ignore="http://www.ignore.com"
        xmlns:views="clr-namespace:FSquirrel.Views"
        xmlns:helper="clr-namespace:FSquirrel.Helpers"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF45"
        mc:Ignorable="d ignore" Title="{Binding LibraryTile, StringFormat='FileSquirrel - Current Library ( {0} )'}"
        DataContext="{Binding Main, Source={StaticResource Locator}}" Height="592" Width="1064" AllowDrop="True" DragOver="Window_DragOver_1" Icon="Images/Squirrel.ico">

    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Skins\MainSkin.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
            <helper:FileSizeConverter x:Key="FileSizeConverter" />
            <helper:BooleanTaskBarProgressConverter x:Key="BooleanTaskBarProgressConverter" />
        </ResourceDictionary>
    </Window.Resources>

    <Window.TaskbarItemInfo>
        <TaskbarItemInfo x:Name="taskBarItemInfo" ProgressState="{Binding Source={StaticResource Locator}, Path=CopierVM.IsCopying, Converter={StaticResource BooleanTaskBarProgressConverter}}" ProgressValue="{Binding Source={StaticResource Locator},Path=CopierVM.CurrentFilePercentageTask}" />
    </Window.TaskbarItemInfo>
    <Grid>
        <views:SettingsView HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch"
                    Width="Auto" Height="Auto" Visibility="{Binding Source={StaticResource Locator},Path=SettingsVM.SettingsVisibility, Converter={StaticResource BooleanToVisibilityConverter}}"
            x:Name="SettingsUserControl" Panel.ZIndex="5"/>

        <views:CopierView HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch"
Width="Auto" Height="Auto" Visibility="{Binding Source={StaticResource Locator},Path=CopierVM.CopierVisibility}"
                          x:Name="CopierUserControl" Panel.ZIndex="5" />

        <DockPanel LastChildFill="False" Panel.ZIndex="1">
            <Ribbon DockPanel.Dock="Top">
                <Ribbon.ApplicationMenu>
                    <RibbonApplicationMenu Visibility="Collapsed"/>
                </Ribbon.ApplicationMenu>
                <RibbonTab Header="Home">
                    <RibbonGroup Header="Files" Name="Files">
                        <RibbonButton Label="Open Library" LargeImageSource="Images/Folder Open.ico" >
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <cmd:EventToCommand Command="{Binding Source={StaticResource Locator},Path=Main.LoadExternalFileCommand}" CommandParameterValue="LIBRARY" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </RibbonButton>
                        <RibbonButton Label="Open Request" LargeImageSource="Images/Export.ico" >
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <cmd:EventToCommand Command="{Binding Source={StaticResource Locator},Path=Main.LoadExternalFileCommand}" CommandParameterValue="REQUEST" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </RibbonButton>

                        <RibbonButton Label="Reload Library" LargeImageSource="Images/Reload.ico" >
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <cmd:EventToCommand Command="{Binding Source={StaticResource Locator},Path=Main.ResetLibraryCommand}" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </RibbonButton>
                    </RibbonGroup>
                    <RibbonGroup Header="Library" Name="Library">
                        <RibbonButton Label="Open Location" LargeImageSource="Images/OpenLocation.ico" Command="{Binding OpenLocationCommand}"/>
                        <RibbonButton Label="Quick Refresh" LargeImageSource="Images/Refresh.ico" IsEnabled="{Binding IsBusyDisable, Mode=OneWay}"  >
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <cmd:EventToCommand Command="{Binding Source={StaticResource Locator},Path=Main.RefreshLibraryCommand}" CommandParameterValue="QUICK"/>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </RibbonButton>
                        <RibbonButton Label="Full Refresh" LargeImageSource="Images/FullRefresh.ico" IsEnabled="{Binding IsBusyDisable, Mode=OneWay}" >
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <cmd:EventToCommand Command="{Binding Source={StaticResource Locator},Path=Main.RefreshLibraryCommand}" CommandParameterValue="FULL"/>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </RibbonButton>
                        <RibbonButton Label="Add to Request" LargeImageSource="Images/Document-Add.ico" >
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <cmd:EventToCommand Command="{Binding Source={StaticResource Locator},Path=Main.RequestCommand}" CommandParameterValue="Add" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </RibbonButton>
                    </RibbonGroup>
                    <RibbonGroup Header="Request" Name="Request">
                        <RibbonButton Label="Clear selected from Request" LargeImageSource="Images/Document-Delete.ico" >
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <cmd:EventToCommand Command="{Binding Source={StaticResource Locator},Path=Main.RequestCommand}" CommandParameterValue="Clear"/>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </RibbonButton>
                    </RibbonGroup>

                    <RibbonGroup Header="Configuration" Name="Config">
                        <RibbonButton Label="Settings" LargeImageSource="Images/Settings.ico" >
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <cmd:EventToCommand Command="{Binding Source={StaticResource Locator},Path=SettingsVM.SettingsCommand}"/>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </RibbonButton>
                    </RibbonGroup>
                </RibbonTab>
            </Ribbon>
            <views:RequestView  Width="300" Height="auto" Visibility="Visible" DockPanel.Dock="Right"
                          x:Name="RequestUserControl" Panel.ZIndex="5" />
            <!--<Button >
                <TextBlock Text="Test" >
                </TextBlock>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <cmd:EventToCommand Command="{Binding Source={StaticResource Locator},Path=SettingsVM.SettingsCommand}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>-->

            <StatusBar DockPanel.Dock="Bottom">
                <StatusBarItem>
                </StatusBarItem>
                <StatusBarItem HorizontalAlignment="Right">
                    <StackPanel Orientation="Horizontal">
                        <StackPanel Orientation="Horizontal" Visibility="{Binding IsBusyRefresh, Converter={StaticResource BooleanToVisibilityConverter}}">
                            <TextBlock Text="{Binding LibUpdateCatName, Mode=OneWay, StringFormat='Updating.. {0}'}"/>
                            <ProgressBar Maximum="{Binding LibUpdateCount, Mode=OneWay}" Value="{Binding LibUpdateIndex, Mode=OneWay}"  Width="54" Margin="5,0"/>
                        </StackPanel>
                        <ProgressBar Maximum="{Binding Source={StaticResource Locator},Path=CopierVM.CopyListCapacity}" Value="{Binding Source={StaticResource Locator},Path=CopierVM.CopyListCount}" Visibility="{Binding Source={StaticResource Locator}, Path=CopierVM.ShowCopy, Converter={StaticResource BooleanToVisibilityConverter}}"  Width="54" Margin="5,0" >
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="MouseUp">
                                    <cmd:EventToCommand Command="{Binding Source={StaticResource Locator},Path=CopierVM.VisibilityCommand}" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </ProgressBar>
                        <Separator/>
                        <TextBlock Text="{Binding Path=ShowListCollection.Count, StringFormat='Item Count : {0}'}" Margin="0,0,5,0"/>
                        <Separator />
                        <Separator/>
                        <TextBlock Text="{Binding Path=TotalSize, Converter={StaticResource FileSizeConverter}, StringFormat='Total Size : {0}'}"  Margin="0,0,5,0"/>
                        <Separator/>
                    </StackPanel>
                </StatusBarItem>
            </StatusBar>
            <StackPanel DockPanel.Dock="Top" HorizontalAlignment="Right" VerticalAlignment="Stretch" Orientation="Horizontal">

                <TextBlock Text="Filter:" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" FontSize="16" Margin="0,5"></TextBlock>
                <TextBox VerticalAlignment="Center" Margin="5,0" Width="271" Text="{Binding Path=FilterText, UpdateSourceTrigger=PropertyChanged, Delay=150}"  x:Name="FilterTextBox">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="TextChanged">
                            <cmd:EventToCommand Command="{Binding Source={StaticResource Locator},Path=Main.CheckAllCommand}" CommandParameterValue="Clear" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </TextBox>
            </StackPanel>
            <views:CategoryTreeView DockPanel.Dock="Left" />
            <views:ShowList DockPanel.Dock="Left"/>

        </DockPanel>
    </Grid>
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Drop">
            <cmd:EventToCommand Command="{Binding Source={StaticResource Locator},Path=Main.FileDropCommand}" PassEventArgsToCommand="True"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
</Window>